# Contributor: Jakub Jirutka <jakub@jirutka.cz>
# Maintainer: Jakub Jirutka <jakub@jirutka.cz>
pkgname=csview
pkgver=1.3.3
pkgrel=0
pkgdesc="Pretty csv viewer for cli with cjk/emoji support"
url="https://github.com/wfxr/csview"
arch="all"
license="Apache-2.0 OR MIT"
makedepends="cargo cargo-auditable"
subpackages="
	$pkgname-bash-completion
	$pkgname-fish-completion
	$pkgname-zsh-completion
	"
source="https://github.com/wfxr/csview/archive/v$pkgver/csview-$pkgver.tar.gz
	update-rust-libc.patch
	"

prepare() {
	default_prepare

	cargo fetch --target="$CTARGET" --locked
}

build() {
	cargo auditable build --frozen --release
}

check() {
	cargo test --frozen
}

package() {
	install -D -m755 target/release/$pkgname -t "$pkgdir"/usr/bin/

	install -D -m644 completions/bash/$pkgname.bash \
		"$pkgdir"/usr/share/bash-completion/completions/$pkgname

	install -D -m644 completions/fish/* -t "$pkgdir"/usr/share/fish/vendor_completions.d/
	install -D -m644 completions/zsh/* -t "$pkgdir"/usr/share/zsh/site-functions/
}

sha512sums="
c50670f2e2dc2ef01d537d4dd44a91a80f8cdfe662d97ce9a07f2deb4773826160e7851c8d2caad8a510ef33bf8ba76777706e3c2fcff38ed5cadcb9027e76aa  csview-1.3.3.tar.gz
6f34884f1fcaea75937a68f7f1f5d1ad6eb9c249f01dfc96e073eaf32c7389c4ad45c46dde6ad88d40bfcbdf0bafb189855f20aa4a12ad7edb9a8d615d82e1b2  update-rust-libc.patch
"
